package com.xmg.mgrsite.base;

import com.xmg.p2p.base.query.UserFileQueryObject;
import com.xmg.p2p.base.service.UserFileService;
import com.xmg.p2p.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserFileController {
    @Autowired
    private UserFileService userFileService;

    @RequestMapping("userFileAuth")
    public String userFileAuth(@ModelAttribute("qo") UserFileQueryObject qo,
                               Model model) {
        model.addAttribute("pageResult", this.userFileService.query(qo));
        return "userFileAuth/list";
    }

    /**
     * 后台风控材料的审核
     */
    @RequestMapping("userFile_audit")
    @ResponseBody
    public JSONResult audit(Long id, String remark, int score, int state) {
        JSONResult json = new JSONResult();
        try {
            this.userFileService.aduit(id,remark,score,state);
        } catch (Exception e) {
            e.printStackTrace();
            json.setSuccess(false);
            json.setMsg(e.getMessage());
        }
        return json;
    }
}
